package com.qf.controller;

import com.qf.util.DownLoadUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/*
杨威
2021/9/18
9:17
*/
@WebServlet("/listFile")
public class ListFileController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String filePath = request.getServletContext().getRealPath("/WEB-INF/upload");
        File file=new File(filePath);
        Map<String,String> map=new HashMap();
        Map<String, String> newMap= DownLoadUtil.fileLists(file, map);
        request.setAttribute("map",map);
        request.getRequestDispatcher("listFile.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
